package cn.dyw.cloudmusic.dao;

import cn.dyw.cloudmusic.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {
    /**
     */
    @Delete({
        "delete from user",
        "where user_id = #{userId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer userId);

    /**
     */
    @Insert({
        "insert into user (user_id, location_info, ",
        "vip_type, user_type, ",
        "nickname, remark_name, ",
        "expert_tags, auth_status, ",
        "experts, avatar_url)",
        "values (#{userId,jdbcType=INTEGER}, #{locationInfo,jdbcType=VARCHAR}, ",
        "#{vipType,jdbcType=INTEGER}, #{userType,jdbcType=INTEGER}, ",
        "#{nickname,jdbcType=VARCHAR}, #{remarkName,jdbcType=VARCHAR}, ",
        "#{expertTags,jdbcType=VARCHAR}, #{authStatus,jdbcType=VARCHAR}, ",
        "#{experts,jdbcType=VARCHAR}, #{avatarUrl,jdbcType=VARBINARY})"
    })
    int insert(User record);

    @Insert({
            "insert into user (user_id, location_info, ",
            "vip_type, user_type, ",
            "nickname, remark_name, ",
            "expert_tags, auth_status, ",
            "experts, avatar_url)",
            "values (#{userId,jdbcType=INTEGER}, #{locationInfo,jdbcType=VARCHAR}, ",
            "#{vipType,jdbcType=INTEGER}, #{userType,jdbcType=INTEGER}, ",
            "#{nickname,jdbcType=VARCHAR}, #{remarkName,jdbcType=VARCHAR}, ",
            "#{expertTags,jdbcType=VARCHAR}, #{authStatus,jdbcType=VARCHAR}, ",
            "#{experts,jdbcType=VARCHAR}, #{avatarUrl,jdbcType=VARBINARY})"
    })
    int insertVo(cn.dyw.cloudmusic.music.vo.User record);

    int insertList(List<cn.dyw.cloudmusic.music.vo.User> records);

    /**
     */
    int insertSelective(User record);

    /**
     */
    @Select({
        "select",
        "user_id, location_info, vip_type, user_type, nickname, remark_name, expert_tags, ",
        "auth_status, experts, avatar_url",
        "from user",
        "where user_id = #{userId,jdbcType=INTEGER}"
    })
    @ResultMap("cn.dyw.cloudmusic.dao.UserMapper.ResultMapWithBLOBs")
    User selectByPrimaryKey(Integer userId);

    /**
     */
    int updateByPrimaryKeySelective(User record);

    /**
     */
    @Update({
        "update user",
        "set location_info = #{locationInfo,jdbcType=VARCHAR},",
          "vip_type = #{vipType,jdbcType=INTEGER},",
          "user_type = #{userType,jdbcType=INTEGER},",
          "nickname = #{nickname,jdbcType=VARCHAR},",
          "remark_name = #{remarkName,jdbcType=VARCHAR},",
          "expert_tags = #{expertTags,jdbcType=VARCHAR},",
          "auth_status = #{authStatus,jdbcType=VARCHAR},",
          "experts = #{experts,jdbcType=VARCHAR},",
          "avatar_url = #{avatarUrl,jdbcType=VARBINARY}",
        "where user_id = #{userId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(User record);

    /**
     */
    @Update({
        "update user",
        "set location_info = #{locationInfo,jdbcType=VARCHAR},",
          "vip_type = #{vipType,jdbcType=INTEGER},",
          "user_type = #{userType,jdbcType=INTEGER},",
          "nickname = #{nickname,jdbcType=VARCHAR},",
          "remark_name = #{remarkName,jdbcType=VARCHAR},",
          "expert_tags = #{expertTags,jdbcType=VARCHAR},",
          "auth_status = #{authStatus,jdbcType=VARCHAR},",
          "experts = #{experts,jdbcType=VARCHAR}",
        "where user_id = #{userId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(User record);
}